import {login,getuser} from "../api/index"
//防止使用vuex存储数据时 刷新页面数据丢失到本地取出
let userInfo = localStorage.getItem("userInfo") || "{}"
userInfo = JSON.parse(userInfo)
export default{
    namespaced: true,
state:{
    stu:[],
    userInfo
},
getter:{},
mutations:{
    "SETUSER"(state,payload){
        state.stu=payload
    },
    "SETUSERINFO"(state,payload){
        state.userInfo = payload
        console.log(state.userInfo);
    }
},
actions:{
    "GETUSER"({commit}){
        getuser()
        .then(res=>{
            console.log(res);
        })
        .catch(err=>{
            console.log(err);
        })
        commit("SETUSER",res)
    }
}

}